package cn.micai.base.lock;

/**
 * 描述：获取锁管理类
 * <p>
 *
 * @author: 赵新国
 * @date: 2018/4/10 15:22
 */
public interface DistributedLocker {

    /**
     * 获取锁
     *
     * @param resourceName 锁的名称
     * @param worker       获取锁后的处理类
     * @param <T>
     * @return 处理完具体的业务逻辑要返回的数据
     * @throws UnableToAquireLockException
     * @throws Exception
     */
    public <T> T lock(String resourceName, AquiredLockWorker<T> worker)
            throws UnableToAquireLockException, Exception;

    public <T> T lock(String resourceName, AquiredLockWorker<T> worker, int lockTime)
            throws UnableToAquireLockException, Exception;
}
